define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'sertec.service_technician/index',
        add_url: 'sertec.service_technician/add',
        edit_url: 'sertec.service_technician/edit',
        delete_url: 'sertec.service_technician/delete',
        export_url: 'sertec.service_technician/export',
        modify_url: 'sertec.service_technician/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh','add'],
                cols: [[
                    {field: 'id', minWidth: 80, title: 'ID',search: false},
                    {field: 'service_name', minWidth: 80, title: '达人名称'},
                    {field: 'service_img', minWidth: 80, title: '头像', search: false, templet: ea.table.image}, 
                    {field: 'phone', minWidth: 80, title: '手机号'},
                    {field: 'sex', title: '性别',selectList: {1: '男',2: '女'}, search: false},
                    {field: 'age', minWidth: 80, title: '年龄', search: false},
                    {field: 'status_type', title: '是否在线',selectList: {0: '离线',1: '在线',2:"忙碌"}},
                    {field: '', title: '状态', templet:function(d) {
                        if (d.status == 0 && d.auditing_status == 1) {
                            return '<a class="layui-btn layui-btn-sm layui-btn-xs"  data-open="sertec.service_technician/golive?id='+d.id+'" data-title="选择项目" data-table="currentTableRenderId">启用</a>';
                        } else if(d.status == 1 && d.auditing_status == 1) {
                            return '<a class="layui-btn layui-btn-danger layui-btn-xs"  data-request="sertec.service_technician/Offline?id='+d.id+'" data-title="确定禁用吗？" data-table="currentTableRenderId">禁用</a>';
                      
                        }else{
                            return "";
                        }
                    }},
                    {field: 'create_time', title: '添加时间',search: false},
                    {title: '操作', templet: function (d) {
                        if(d.status == 1 && d.status_type == 1){
                            return '<button class="layui-btn layui-btn-xs layui-btn-danger" data-request="sertec.service_technician/off_line_url?id='+d.id+'"  data-title="确定离线吗？">离线</button>' +
                            '<button class="layui-btn layui-btn-xs layui-btn-blue" data-request="sertec.service_technician/busy_url?id='+d.id+'"  data-title="确定忙碌吗？">忙碌</button>';
                        }else if(d.status == 1 && d.status_type == 0){
                            return '<button class="layui-btn layui-btn-xs layui-btn-success" data-request="sertec.service_technician/golive_url?id='+d.id+'"  data-title="确定上线吗？">上线</button>';
                        }else if(d.status == 1 && d.status_type == 2){
                            return '<button class="layui-btn layui-btn-xs layui-btn-success" data-request="sertec.service_technician/golive_url?id='+d.id+'"  data-title="确定上线吗？">上线</button>'+
                            '<button class="layui-btn layui-btn-xs layui-btn-danger" data-request="sertec.service_technician/off_line_url?id='+d.id+'"  data-title="确定离线吗？">离线</button>';
                        }
                            return '<button class="layui-btn layui-btn-xs layui-btn-success" data-open="sertec.service_technician/edit?id='+d.id+'"  data-title="编辑">编辑</button>' +
                            '<button class="layui-btn layui-btn-xs layui-btn-danger" data-request="sertec.service_technician/delete?id='+d.id+'"  data-title="删除">删除</button>';
                        }
                    },
                
                ]],
            });
            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        golive: function () {
            ea.listen();
        },
        reject_url: function () {
            ea.listen();
        }
    };
    return Controller;
});